package com.mall.shopping.dal.entitys;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 *
 */
@Data
@TableName("tb_panel_content")
@Table(name = "tb_panel_content_item")
public class PanelContentItem {

    @TableId(type = IdType.AUTO)
    @Id
    @KeySql(useGeneratedKeys = true)
    private Integer id;

    @TableField("panel_id")
    private Integer panelId;

    private Integer type;

    @TableField("product_id")
    private Long productId;

    private Integer sortOrder;

    private String fullUrl;

    private String picUrl;

    private String picUrl2;

    private String picUrl3;

    private Date created;

    private Date updated;

    @TableField("title")
    private String productName;// 连表tb_item，字段title

    @TableField("price")
    private BigDecimal salePrice;// 连表tb_item，字段price

    @TableField("sell_point")
    private String subTitle;// 连表tb_item，字段sell_point

    @TableField(exist = false)// 多对一
    @ManyToOne
    @JoinColumn(name = "panel_id", referencedColumnName = "id") //相关的@TableField与多方的@TableId名称一致时@JoinColumn可省略
    private Panel panel;

    @TableField(exist = false)// 多对一
    @OneToOne
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    private Item item;
}
